<?php
// +---------------------------------------------------------------------+
// | ALINEJUN    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/ALINEJUN                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

/**
 * 留言控制器
 */
class Msg extends AdminBase
{
    
    /**
     * 留言列表
     */
    public function msgList()
    {
        
        $where = $this->logicmsg->getWhere($this->param);

        $this->assign('list', $this->logicMsg->getMsgList($where, '*', 'create_time desc'));
        
        return $this->fetch('msg_list');
    }
    
    /**
     * 留言添加
     */
    public function msgAdd()
    {
        
        $this->msgCommon();
        
        return $this->fetch('msg_edit');
    }
    
    /**
     * 留言编辑
     */
    public function msgEdit()
    {
        
        $this->msgCommon();
        
        $info = $this->logicmsg->getmsgInfo(['id' => $this->param['id']], '*');

        
        $this->assign('info', $info);
        
        return $this->fetch('msg_edit');
    }
    
    /**
     * 留言添加与编辑通用方法
     */
    public function msgCommon()
    {
        
        IS_POST && $this->jump($this->logicmsg->msgEdit($this->param));
        
        //$this->assign('msg_category_list', $this->logicmsg->getmsgCategoryList([], 'id,name', '', false));
    }
    /**
     * 留言分类删除
     */
    public function msgCategoryDel($id = 0)
    {
        
        $this->jump($this->logicmsg->msgCategoryDel(['id' => $id]));
    }
    
    /**
     * 数据状态设置
     */
    public function setStatus()
    {
        
        $this->jump($this->logicAdminBase->setStatus('msg', $this->param));
    }
}
